﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>简易智云服务平台SSO认证中心</title>
    <!-- Mobile specific metas -->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <!-- Force IE9 to render in normal mode -->
    <!--[if IE]><meta http-equiv="x-ua-compatible" content="IE=9" /><![endif]-->
    <meta name="author" content="SuggeElson" />
    <meta name="description" content="" />
    <meta name="keywords" content="简易智云服务平台" />
    <meta name="application-name" content="sprFlat admin template" />
    <!-- Import google fonts - Heading first/ text second -->
    <link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Open+Sans:400,700|Droid+Sans:400,700' />
    <!--[if lt IE 9]>
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:400" rel="stylesheet" type="text/css" />
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:700" rel="stylesheet" type="text/css" />
    <link href="http://fonts.googleapis.com/css?family=Droid+Sans:400" rel="stylesheet" type="text/css" />
    <link href="http://fonts.googleapis.com/css?family=Droid+Sans:700" rel="stylesheet" type="text/css" />
    <![endif]-->
    <!-- Css files -->
    <!-- Icons -->
    <link href="~/Content/assets/css/icons.css" rel="stylesheet" />
    <!-- jQueryUI -->
    <link href="~/Content/assets/css/sprflat-theme/jquery.ui.all.css" rel="stylesheet" />
    <!-- Bootstrap stylesheets (included template modifications) -->
    <link href="~/Content/assets/css/bootstrap.css" rel="stylesheet" />
    <!-- Plugins stylesheets (all plugin custom css) -->
    <link href="~/Content/assets/css/plugins.css" rel="stylesheet" />
    <!-- Main stylesheets (template main css file) -->
    <link href="~/Content/assets/css/main.css" rel="stylesheet" />
    <!-- Custom stylesheets ( Put your own changes here ) -->
    <link href="~/Content/assets/css/custom.css" rel="stylesheet" />
    <!-- Fav and touch icons -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="~/Content/assets/img/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="~/Content/assets/img/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="~/Content/assets/img/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="~/Content/assets/img/ico/apple-touch-icon-57-precomposed.png">
    <link rel="icon" href="~/Content/assets/img/ico/favicon.ico" type="image/png">
    <meta name="msapplication-TileColor" content="#3399cc" />
    <script>
        //向Url中加参数
        function addParamToUrl(url, paramName, paramValue) {
            var num = url.indexOf("?");
            //目前无参数则直接在后面加参数
            if (num == -1) {
                url = url + "?" + paramName + "=" + paramValue;
            }
            else {
                var arr = url.split("?");
                //后面无参数则直接加参数
                if (arr[1] == "" || arr[1] == undefined || arr[1] == null) {
                    url = url + paramName + "=" + paramValue;
                }
                //有参数要加参数分隔符
                else {
                    //获取所有参数
                    var params = arr[1].split("&");
                    //只有一个参数直接在后面加
                    if (params.length == 1) {
                        url = url + "&" + paramName + "=" + paramValue;
                    }
                    //有多个参数
                    else {
                        //最后一个参数不存在
                        var lastparam = params[params.length - 1];
                        if (lastparam == null || lastparam == "" || lastparam == undefined) {
                            url = url + paramName + "=" + paramValue;
                        }
                        else {
                            url = url + "&" + paramName + "=" + paramValue;
                        }
                    }
                }
            }
            return url;
        }
        
        //登录中心自己的登录
        function onlogin(){
            $.ajax({
                type: "Post",
                url: "@Url.Action("Login", "Account")",
                data: {
                    username: $('#username').val(),
                    password: $('#password').val(),
                    returnUrl : "@ViewBag.ReturnUrl"
                },
                dataType: "json",
                success: function (data) {
                    console.log(data);
                    if (data.IsSucceed) {
                        //重定向回原页面
                        //添加Ticket参数
                        var returnUrl = addParamToUrl(data.ReturnUrl, "UserAuthTicket", data.Ticket);
                        //添加UserName参数
                        returnUrl = addParamToUrl(returnUrl, "UserName", data.UserInfo);
                        console.log(returnUrl);
                        document.location = returnUrl;
                    }
                    else {
                        alert(data.ErrorMsg);
                    }
                }
            });
        };

        //登录中心跨域设置分站的Cookie
        function setCookie(url, param) {
            $.ajax({
                type: "get",
                async: false,
                url: url,
                dataType: "jsonp",
                crossDomain: true,
                jsonp: "callback",
                jsonpCallback: "flightHandler",
                data:param,
                success: function (data) {
                },
                error: function () {
                    alert('调用失败');
                }
            });
        }
    </script>
</head>
<body class="login-page">
    <!-- Start #login -->
    <div id="login" class="animated bounceIn">
        <img id="logo" src="~/Content/assets/img/logo.png" alt="sprFlat Logo">
        <!-- Start .login-wrapper -->
        <div class="login-wrapper">
            <ul id="myTab" class="nav nav-tabs nav-justified bn">
                <li>
                    <a href="#log-in" data-toggle="tab">登录</a>
                </li>
                <li class="">
                    <a href="#register" data-toggle="tab">注册</a>
                </li>
            </ul>
            <div id="myTabContent" class="tab-content bn">
                <div class="tab-pane fade active in" id="log-in">
                    <div class="social-buttons text-center mt10">
                        <a href="#" class="btn btn-primary btn-alt btn-round btn-lg mr10"><i class="fa-facebook s24"></i></a>
                        <a href="#" class="btn btn-primary btn-alt btn-round btn-lg mr10"><i class="fa-twitter s24"></i></a>
                        <a href="#" class="btn btn-danger btn-alt btn-round btn-lg mr10"><i class="fa-google-plus s24"></i></a>
                        <a href="#" class="btn btn-info btn-alt btn-round btn-lg"><i class="fa-linkedin s24"></i></a>
                    </div>
                    <div class="seperator">
                        <strong>or</strong>
                        <hr>
                    </div>
                    <div class="form-horizontal mt10" id="login-form" role="form">
                        <div class="form-group">
                            <div class="col-lg-12">
                                <input type="text" name="username" id="username" class="form-control left-icon" placeholder="用户名">
                                <i class="ec-user s16 left-input-icon"></i>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-12">
                                <input type="password" name="password" id="password" class="form-control left-icon" placeholder="密码">
                                <i class="ec-locked s16 left-input-icon"></i>
                                <span class="help-block"><a href="#"><small>忘记密码 ?</small></a></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-8">
                                <!-- col-lg-12 start here -->
                                <label class="checkbox">
                                    <input type="checkbox" name="remember" id="remember" value="option">记住我一周 ?
                                </label>
                            </div>
                            <!-- col-lg-12 end here -->
                            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-4">
                                <!-- col-lg-12 start here -->
                                <button class="btn btn-success pull-right" type="button" onclick="onlogin()">登录</button>
                            </div>
                            <!-- col-lg-12 end here -->
                        </div>
                    </div>
                </div>
                <div class="tab-pane fade" id="register">
                    <div class="form-horizontal mt20" action="#" id="register-form" role="form">
                        <div class="form-group">
                            <div class="col-lg-12">
                                <!-- col-lg-12 start here -->
                                <input id="email1" name="email" type="email" class="form-control left-icon" placeholder="你的邮箱">
                                <i class="ec-mail s16 left-input-icon"></i>
                            </div>
                            <!-- col-lg-12 end here -->
                        </div>
                        <div class="form-group">
                            <div class="col-lg-12">
                                <!-- col-lg-12 start here -->
                                <input type="password" class="form-control left-icon" id="password1" name="password" placeholder="你的密码">
                                <i class="ec-locked s16 left-input-icon"></i>
                            </div>
                            <!-- col-lg-12 end here -->
                            <div class="col-lg-12 mt15">
                                <!-- col-lg-12 start here -->
                                <input type="password" class="form-control left-icon" id="confirm_password" name="confirm_passowrd" placeholder="确认密码">
                                <i class="ec-locked s16 left-input-icon"></i>
                            </div>
                            <!-- col-lg-12 end here -->
                        </div>
                        <div class="form-group">
                            <div class="col-lg-12">
                                <!-- col-lg-12 start here -->
                                <button class="btn btn-success btn-block">注册</button>
                            </div>
                            <!-- col-lg-12 end here -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- End #.login-wrapper -->
    </div>
    <!-- End #login -->
    <!-- Javascripts -->
    <!-- Load pace first -->
    <script src="~/Content/assets/plugins/core/pace/pace.min.js"></script>
    <!-- Important javascript libs(put in all pages) -->
    @*<script src="~/Content/assets/js/jquery-1.8.3.min.js"></script>*@
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script>
        window.jQuery || document.write('<script src="~/Content/assets/js/libs/jquery-2.1.1.min.js">\x3C/script>')
    </script>
    <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <script>
        window.jQuery || document.write('<script src="~/Content/assets/js/libs/jquery-ui-1.10.4.min.js">\x3C/script>')
    </script>
    <!--[if lt IE 9]>
      <script type="text/javascript" src="assets/js/libs/excanvas.min.js"></script>
      <script type="text/javascript" src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
      <script type="text/javascript" src="assets/js/libs/respond.min.js"></script>
    <![endif]-->
    <!-- Bootstrap plugins -->
    <script src="~/Content/assets/js/bootstrap/bootstrap.js"></script>
    <!-- Form plugins -->
    <script src="~/Content/assets/plugins/forms/icheck/jquery.icheck.js"></script>
    <script src="~/Content/assets/plugins/forms/validation/jquery.validate.js"></script>
    <script src="~/Content/assets/plugins/forms/validation/additional-methods.min.js"></script>
    <!-- Init plugins olny for this page -->
    <script src="~/Content/assets/js/pages/login.js"></script>
</body>
</html>